document.onkeydown = function (event) {
    var target, code, tag;
    if (!event) {
        event = window.event; //针对ie浏览器
        target = event.srcElement;
        code = event.keyCode;
        if (code == 13) {
            tag = target.tagName;
            if (tag == "TEXTAREA") {
                return true;
            } else {
                return false;
            }
        }
    } else {
        target = event.target; //针对遵循w3c标准的浏览器，如Firefox
        code = event.keyCode;
        if (code == 13) {
            tag = target.tagName;
            if (tag == "INPUT") {
                return false;
            } else {
                return true;
            }
        }
    }
};

//------- Start 判断输入的是否是证书和小数还有0

function CupperCase(obj) {//用户只能输入正负数与小数

    var inum = 6;
    var newValue;

    if (inum == 1) {

        if (isNaN(obj.value) && !/^-$/.test(obj.value)) {
            obj.value = "";
        }
        if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(obj.value)) {
            obj.value = obj.value.replace(/\.\d{1,}$/, obj.value.substr(obj.value.indexOf('.'), inum));
            obj.value = newValue.replace('.', '');
        }
    } else {

        if (isNaN(obj.value) && !/^-$/.test(obj.value)) {
            obj.value = "";
        }
        if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(obj.value)) {
            obj.value = obj.value.replace(/\.\d{1,}$/, obj.value.substr(obj.value.indexOf('.'), inum));
        }
    }
}

function CupperCase6(obj) {//用户只能输入正负数与小数

    var inum = 6;
    var newValue;

    if (inum == 1) {

        if (isNaN(obj.value) && !/^-$/.test(obj.value)) {
            obj.value = "";
        }
        if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(obj.value)) {
            obj.value = obj.value.replace(/\.\d{1,}$/, obj.value.substr(obj.value.indexOf('.'), inum));
            obj.value = newValue.replace('.', '');
        }
    } else {

        if (isNaN(obj.value) && !/^-$/.test(obj.value)) {
            obj.value = "";
        }
        if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(obj.value)) {
            obj.value = obj.value.replace(/\.\d{1,}$/, obj.value.substr(obj.value.indexOf('.'), inum));
        }
    }
}


function Wonkeyup(obj) {//用户只能输入正负数与小数

    var inum = 6;

    // if(inum.length==5){inum==4;}else{inum=3;}

    if (isNaN(obj.value) && !/^-$/.test(obj.value)) {
        obj.value = "";
    }
    if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(obj.value)) {
        obj.value = obj.value.replace(/\.\d{1,}$/, obj.value.substr(obj.value.indexOf('.'), inum));
    }
}

//------- End 判断输入的是否是证书和小数还有0


function Button2_onclick() {
    var mymessage = confirm("你确定需要保存吗？或者在检查一遍？");

    if (mymessage == true) {
        return true;


    } else {
        return false;
    }

}


function ResoultFloat(arg1, arg2) {
    var t1 = 0, t2 = 0, r1, r2;
    try {
        t1 = arg1.toString().split(".")[1].length
    } catch (e) {
    }
    try {
        t2 = arg2.toString().split(".")[1].length
    } catch (e) {
    }
    with (Math) {
        r1 = Number(arg1.toString().replace(".", ""));
        r2 = Number(arg2.toString().replace(".", ""));
        return (r1 / r2) * pow(10, t2 - t1);
    }

}


function _SetDigitalInput(oInput) {

    var isnum = 5;
    if (oInput == 2 || oInput == 10 || oInput == 18 || oInput == 26 || oInput == 34 || oInput == 42 || oInput == 50 || oInput == 58 || oInput == 66 || oInput == 74 || oInput == 82 || oInput == 90) {
 
        var f = oInput + 1;
        var r = oInput - 1;
        var k = oInput + 2;
        var g = oInput + 3;

        var f_01 = parseFloat(document.getElementById("C" + oInput).value) - parseFloat(document.getElementById("C" + r).value);

        document.getElementById("C" + f).value = changeTwoDecimal_y(f_01, 5);

        var f_02 = (document.getElementById("C" + k).value) == "" ? 0 : parseFloat(document.getElementById("C" + k).value);

        var f_03 = f_02 - f_01 * (oInput <= 73 ? 1000 : 1000000);

        document.getElementById("C" + g).value = changeTwoDecimal_y(f_03, 5);


    }

    if (oInput == 4 || oInput == 12 || oInput == 20 || oInput == 28 || oInput == 36 || oInput == 44 || oInput == 52 || oInput == 60 || oInput == 68 || oInput == 76 || oInput == 84 || oInput == 92) {


        var i = oInput - 1;
        var j = oInput + 1;
        var r_01 = (document.getElementById("C" + oInput).value) == "" ? 0 : parseFloat(document.getElementById("C" + oInput).value);
        var r_02 = (document.getElementById("C" + i).value) == "" ? 0 : parseFloat(document.getElementById("C" + i).value);

        var f_y = r_01 - r_02 * (oInput <= 73 ? 1000 : 1000000);

        document.getElementById("C" + j).value = changeTwoDecimal_y(f_y, 5);


    }

    if (oInput == 2 || oInput == 4 || oInput == 10 || oInput == 12 || oInput == 18 || oInput == 20) {


        var fV02 = (document.getElementById("C5").value) == "" ? 0 : parseFloat(document.getElementById("C5").value);
        var fV01 = (document.getElementById("C13").value) == "" ? 0 : parseFloat(document.getElementById("C13").value);
        var fV03 = (document.getElementById("C21").value) == "" ? 0 : parseFloat(document.getElementById("C21").value);


        var f_d = fV02 + fV01 + fV03;

        var f_x = ResoultFloat(f_d * 10000, 3) / 10000;


        document.getElementById("C6").value = document.getElementById("C14").value = document.getElementById("C22").value = changeTwoDecimal_y(f_x, 5);
    }

    if (oInput == 26 || oInput == 34 || oInput == 28 || oInput == 42 || oInput == 36 || oInput == 44) {


        var rV02 = document.getElementById("C29").value == "" ? 0 : parseFloat(document.getElementById("C29").value);
        var rV01 = document.getElementById("C37").value == "" ? 0 : parseFloat(document.getElementById("C37").value);
        var rV03 = document.getElementById("C45").value == "" ? 0 : parseFloat(document.getElementById("C45").value);

        var r_d = rV02 + rV01 + rV03;

        var r_x = ResoultFloat(r_d * 10000, 3) / 10000;


        document.getElementById("C30").value = document.getElementById("C38").value = document.getElementById("C46").value = changeTwoDecimal_y(r_x, 3);
    }

    if (oInput == 50 || oInput == 52 || oInput == 58 || oInput == 60 || oInput == 66 || oInput == 68) {


        var xV02 = document.getElementById("C53").value == "" ? 0 : parseFloat(document.getElementById("C53").value);
        var xV01 = document.getElementById("C61").value == "" ? 0 : parseFloat(document.getElementById("C61").value);
        var xV03 = document.getElementById("C69").value == "" ? 0 : parseFloat(document.getElementById("C69").value);

        var x_d = xV02 + xV01 + xV03;

        var x_x = ResoultFloat(x_d * 10000, 3) / 10000;


        document.getElementById("C54").value = document.getElementById("C62").value = document.getElementById("C70").value = changeTwoDecimal_y(x_x, 3);
    }

    if (oInput == 74 || oInput == 76 || oInput == 82 || oInput == 84 || oInput == 90 || oInput == 92) {


        var yV02 = document.getElementById("C77").value == "" ? 0 : parseFloat(document.getElementById("C77").value);
        var yV01 = document.getElementById("C85").value == "" ? 0 : parseFloat(document.getElementById("C85").value);
        var yV03 = document.getElementById("C93").value == "" ? 0 : parseFloat(document.getElementById("C93").value);

        var y_d = yV02 + yV01 + yV03;

        var y_x = ResoultFloat(y_d * 10000, 3) / 10000;


        document.getElementById("C78").value = document.getElementById("C86").value = document.getElementById("C94").value = changeTwoDecimal_y(y_x, 3);
    }


}


function SetDigitalInput(oInput) {

    var isnum = 5;

    var i = oInput - 1;
    var j = oInput + 1;
    var k = oInput - 2;
    var m = oInput - 3;


    // var f_01 = parseFloat(document.getElementById("C" + oInput).value);
    // var f_02 = parseFloat(document.getElementById("C" + i).value);

    if (document.getElementById("C" + oInput).value == "") {

        f_01 = 0;

    } else {

        f_01 = parseFloat(document.getElementById("C" + oInput).value);
    }

    if (document.getElementById("C" + i).value == "") {

        f_02 = 0;

    } else {

        f_02 = parseFloat(document.getElementById("C" + i).value);
    }

    if (oInput == 76 || oInput == 84 || oInput == 92) {


        var f_y = f_01 - (f_02) * 1000000;


        document.getElementById("C" + j).value = changeTwoDecimal_y(f_y, isnum);

    } else {

        var f_f = f_01 - f_02 * 1000;

        document.getElementById("C" + j).value = changeTwoDecimal_y(f_f, isnum);

    }

    if (oInput == 20 || oInput == 44 || oInput == 68 || oInput == 92) {

        var k = oInput + 1;
        var k1 = k - 8;
        var k2 = k - 8 - 8;

        var fV02 = parseFloat(document.getElementById("C" + k).value);
        var fV01 = parseFloat(document.getElementById("C" + k1).value);
        var fV03 = parseFloat(document.getElementById("C" + k2).value);


        var f_d = fV02 + fV01 + fV03;

        var f_x = ResoultFloat(f_d * 10000, 3) / 10000;

        var x = oInput + 2;
        var x1 = x - 8;
        var x2 = x - 8 - 8;

        document.getElementById("C" + x).value = document.getElementById("C" + x1).value = document.getElementById("C" + x2).value = changeTwoDecimal_y(f_x, 3);
    } else if (oInput == 4 || oInput == 28 || oInput == 52 || oInput == 76) {


        var e = oInput + 1;
        var e1 = e + 8;
        var e2 = e + 8 + 8;

        //var fV02e = parseFloat(document.getElementById("C" + e).value);
        //var fV01e = parseFloat(document.getElementById("C" + e1).value);
        // var fV03e = parseFloat(document.getElementById("C" + e2).value);

        if (document.getElementById("C" + e).value == "") {

            fV02e = 0;
        } else {

            fV02e = parseFloat(document.getElementById("C" + e).value);
        }

        if (document.getElementById("C" + e1).value == "") {

            fV01e = 0;
        } else {

            fV01e = parseFloat(document.getElementById("C" + e1).value);
        }
        if (document.getElementById("C" + e2).value == "") {

            fV03e = 0;
        } else {

            fV03e = parseFloat(document.getElementById("C" + e2).value);
        }


        var f_de = fV02e + fV01e + fV03e;

        var f_xe = ResoultFloat(f_de * 10000, 3) / 10000;

        var xe = oInput + 2;
        var xe1 = xe + 8;
        var xe2 = xe + 8 + 8;

        document.getElementById("C" + xe).value = document.getElementById("C" + xe1).value = document.getElementById("C" + xe2).value = changeTwoDecimal_y(f_xe, 3);


    } else if (oInput == 12 || oInput == 36 || oInput == 60 || oInput == 84) {


        var ee = oInput + 1;
        var ee1 = ee - 8;
        var ee2 = ee + 8;

        //var fV02e = parseFloat(document.getElementById("C" + e).value);
        //var fV01e = parseFloat(document.getElementById("C" + e1).value);
        // var fV03e = parseFloat(document.getElementById("C" + e2).value);

        if (document.getElementById("C" + ee).value == "") {

            fV02ee = 0;
        } else {

            fV02ee = parseFloat(document.getElementById("C" + ee).value);
        }

        if (document.getElementById("C" + ee1).value == "") {

            fV01ee = 0;
        } else {

            fV01ee = parseFloat(document.getElementById("C" + ee1).value);
        }
        if (document.getElementById("C" + ee2).value == "") {

            fV03ee = 0;
        } else {

            fV03ee = parseFloat(document.getElementById("C" + ee2).value);
        }


        var f_dee = fV02ee + fV01ee + fV03ee;

        var f_xee = ResoultFloat(f_dee * 10000, 3) / 10000;

        var xee = oInput + 2;
        var xee1 = xee - 8;
        var xee2 = xee + 8;

        document.getElementById("C" + xee).value = document.getElementById("C" + xee1).value = document.getElementById("C" + xee2).value = changeTwoDecimal_y(f_xee, 3);


    }

}

function SetDigitalInputB(oInput) {
    var inum = 5;


    var f_1 = document.getElementById("B0").value == "" ? 0 : parseFloat(document.getElementById("B0").value);

    var f_2 = document.getElementById("B4").value == "" ? 0 : parseFloat(document.getElementById("B4").value);

    var f_3 = document.getElementById("B8").value == "" ? 0 : parseFloat(document.getElementById("B8").value);

    var f_4 = document.getElementById("B12").value == "" ? 0 : parseFloat(document.getElementById("B12").value);

    var f_5 = document.getElementById("B16").value == "" ? 0 : parseFloat(document.getElementById("B16").value);

    var f_6 = document.getElementById("B20").value == "" ? 0 : parseFloat(document.getElementById("B20").value);


    var f_d = f_1 + f_2 + f_3 + f_4 + f_5 + f_6;


    var Avg_x = changeTwoDecimal_y(ResoultFloat(f_d * 10000, 6) / 10000, inum);

    // document.getElementById("B1").innerText = Avg_x;

    document.getElementById("B5").value = Avg_x;


    // document.getElementById("B1").value = document.getElementById("B5").value= document.getElementById("B9").value = document.getElementById("B13").value = document.getElementById("B17").value = document.getElementById("B21").value = Avg_x;

    var J_1 = (f_1 - Avg_x) * (f_1 - Avg_x);
    var J_2 = (f_2 - Avg_x) * (f_2 - Avg_x);
    var J_3 = (f_3 - Avg_x) * (f_3 - Avg_x);
    var J_4 = (f_4 - Avg_x) * (f_4 - Avg_x);
    var J_5 = (f_5 - Avg_x) * (f_5 - Avg_x);
    var J_6 = (f_6 - Avg_x) * (f_6 - Avg_x);

    var s_7 = (J_1 + J_2 + J_3 + J_4 + J_5 + J_6) / 5;


    var f_f = Math.pow(parseFloat(s_7), 0.5);


    // document.getElementById("B2").innerText = changeTwoDecimal_y(f_f, inum);
    document.getElementById("B6").value = changeTwoDecimal_y(f_f, inum);


    document.getElementById("B3").value = "≤3 %";


    // document.getElementById("B2").value = document.getElementById("B6").value = document.getElementById("B10").value = document.getElementById("B14").value = document.getElementById("B18").value = document.getElementById("B22").value = changeTwoDecimal_y(f_f,inum);


}

function changeTwoDecimal_f(x) {
    var f_x = parseFloat(x);
    if (isNaN(f_x)) {
        alert('function:changeTwoDecimal->parameter error');
        return false;
    }
    f_x = Math.round(f_x * 10000) / 10000;
    var s_x = f_x.toString();
    var pos_decimal = s_x.indexOf('.');
    if (pos_decimal < 0) {
        pos_decimal = s_x.length;
        s_x += '.';
    }
    while (s_x.length <= pos_decimal + 3) {
        s_x += '0';
    }
    return s_x;
}

function changeTwoDecimal_y(s_x, inum) {

    var s_x_old = s_x;

    if (String(s_x).length >= 10) {

        s_x = s_x.toFixed(inum + 1);

    }

    if (isNaN(s_x)) {
        alert('function:changeTwoDecimal->parameter error');
        return false;
    }

    // 转成字符型

    s_x = s_x.toString();


    //确定是否有小数点

    var pdecimal = s_x.indexOf('.');


    if (pdecimal < 0) {
        pdecimal = s_x.length;
        s_x += '.';
    }

    while (s_x.length < parseInt(parseInt(pdecimal) + parseInt(inum + 2))) {
        s_x += '0';
    }


    var inums = inum + s_x.indexOf('.');


    var iReturnValue = "";


    if (s_x.length > (parseInt(inums) + 2)) {
        s_x = s_x.substring(0, (parseInt(inums) + 2));
    }


    var s_x_l = parseInt(s_x.substring(s_x.length - 1, s_x.length));

    var s_x_2 = parseInt(s_x.substring(s_x.length - 2, s_x.length - 1));


    var kj = parseFloat(Math.pow(10, -inum).toFixed(inum));


    if (s_x_l == 5) {


        if (Math.abs(parseFloat(s_x_old)) > Math.abs(parseFloat(s_x))) {


            iReturnValue = parseFloat(s_x) > 0 ? String((parseFloat(s_x.substring(0, parseInt(inums + 1))) * 1000000 + kj * 1000000) / 1000000) : String((parseFloat(s_x.substring(0, parseInt(inums + 1))) * 1000000 - kj * 1000000) / 1000000);


        } else {

            if (s_x_2 == 0 || s_x_2 % 2 == 0) {

                iReturnValue = (s_x.substring(0, parseInt(inums + 1)));


            } else if (s_x_2 != 0 && s_x_2 % 2 != 0) {

                iReturnValue = parseFloat(s_x) > 0 ? String((parseFloat(s_x.substring(0, parseInt(inums + 1))) * 1000000 + kj * 1000000) / 1000000) : String((parseFloat(s_x.substring(0, parseInt(inums + 1))) * 1000000 - kj * 1000000) / 1000000);


            }
        }
    } else {


        if (s_x_l >= 6) {


            iReturnValue = parseFloat(s_x) > 0 ? String((parseFloat(s_x.substring(0, parseInt(inums + 1))) * 1000000 + kj * 1000000) / 1000000) : String((parseFloat(s_x.substring(0, parseInt(inums + 1))) * 1000000 - kj * 1000000) / 1000000);


        } else {

            iReturnValue = (s_x.substring(0, parseInt(inums + 1)));


        }

    }

    return iReturnValue;
}

function Setnum(oInput) {
    var f_x = parseFloat(document.getElementById("A1PH_Dy10").value);

    document.getElementById("C49").value = f_x;
    document.getElementById("C98").value = -f_x;
    document.getElementById("C106").value = f_x;

}


var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}

function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
